# !/usr/bin/python
# _*_ coding: utf-8 _*_
# @Time : 2021/5/25 3:29 下午
# @Author : liujun
# @File : blog_sort.py
# @desc : 博客分类CURD
from sqlalchemy.orm import Session

from models import BlogSort
from service.base import Base
from schemas.request.blog_sort import BlogSortAdd, BlogSortUpd


class BlogSort(Base[BlogSort, BlogSortAdd, BlogSortUpd]):

    def get_list(self, db: Session, page_number: int, page_size: int, sort_name: str, sort_order: str,
                 name: str, state: int):
        filters = {}
        if name is not None:
            filters['name_like'] = name
        if state is not None:
            filters['state'] = state
        return self.get_multi(db, filters=filters,
                              sort_name=sort_name, sort_order=sort_order, page_number=page_number, page_size=page_size)


BolgSortService = BlogSort(BlogSort)
